
import 'package:flutter/material.dart';

class MsgDialog {
  final BuildContext context;
  MsgDialog(this.context);

  Future<bool?> showAlertDialog(
      String title,
      String msg,
      String confirmText,
      String cancelText,
      ){
    return showDialog<bool>(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: Text(title),
          content: Text(msg),
          actions: <Widget>[
            TextButton(
              child: Text(cancelText),
              onPressed: () => Navigator.of(context).pop(), // 关闭对话框
            ),
            TextButton(
              child: Text(confirmText),
              onPressed: () {
                //关闭对话框并返回true
                Navigator.of(context).pop(true);
              },
            ),
          ],
        );
      },
    );
  }

  Future<bool?> showDefaultDialog(String msg){
    return showAlertDialog(
      "通知", msg,
      "确定", "取消",
    );
  }


}